package com.opc.Config;

import java.util.concurrent.ConcurrentHashMap;

public class CacheUtil {
       private static ConcurrentHashMap<String, Object> cache = new ConcurrentHashMap<>();
       public static Object getFromCache(String key) {
           return cache.get(key);
       }
       public static void putInCache(String key, Object value) {
           cache.put(key, value);
       }
    // 新增方法：清除指定的缓存条目
    public static void removeFromCache(String key) {
        if (key != null) {
            cache.remove(key);
        } else {
            throw new IllegalArgumentException("Cache key cannot be null");
        }
    }
    // 新增方法：清除所有缓存条目
    public static void clearCache() {
        cache.clear();
    }
   }